package com.good.shopping.order.feign;

import com.good.common.base.ServiceConstant;
import com.good.common.utils.R;
import com.good.shopping.order.vo.WareSkuLockVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 库存 - 远程服务
 * @author shengren.yan
 * @create 2022-03-17
 */
@FeignClient(value = ServiceConstant.SERVICE_WARE_NAME)
public interface WmsFeignService {

    /**
     * 查询sku是否有库存
     * @return
     */
    @PostMapping(value = "/ware/waresku/hasStock")
    R getSkuHasStock(@RequestBody List<Long> skuIds);



    /**
     * 查询运费和收货地址信息
     * @param addrId
     * @return
     */
    @GetMapping(value = "/ware/wareinfo/fare")
    R getFare(@RequestParam("addrId") Long addrId);


    /**
     * 锁定库存
     * @param vo
     * @return
     */
    @PostMapping(value = "/ware/waresku/lock/order")
    R orderLockStock(@RequestBody WareSkuLockVo vo);

    // 测试远程分布式锁
    @PostMapping(value = "/ware/waresku/test/seata")
    R testSeata(@RequestBody WareSkuLockVo vo);

}
